const fs = require('fs')

function createPromise(name) {
  return new Promise((resolve, reject) => {
    fs.readFile(`${__dirname}/${name}.txt`, 'utf-8', (err, data) => {
      if (data) {
        resolve(data)
      } else {
        reject(err)
      }
    })
  })
}

async function readFile() {
  try {
    let res1 = await createPromise('a')
    console.log(res1);

    let res2 = await createPromise('b')
    console.log(res2);

    let res3 = await createPromise('c')
    console.log(res3);

  } catch (error) {
    console.log(err);
  }

}
readFile()






// let p1 = createPromise('a')
// let p2 = createPromise('b')
// let p3 = createPromise('c')

// p1.then(data => {
//   console.log(data);
//   return p2
// }).then(data => {
//   console.log(data);
//   return p3
// }).then(data => {
//   console.log(data);

// })
